define(['app'], function(app) {
	'use strict';

	var controller = function controller($scope, $rootScope, GoWapAuth, Home, Auth, GoPage, GoDialog, GoAddress, GoMap, GoPicture, $window, $timeout, $interval, $ionicSlideBoxDelegate, $ionicScrollDelegate, $ionicModal, $ionicPopover, $sce, GoScan, $animateCss) {
		
		//初始化关键字
		$scope.input = new Object();
		$scope.input.province = {id:0,name:"请选择省份"}; //省市区三级联动
		$scope.input.city = {id:0,name:"请选择城市"}; //省市区三级联动
		$scope.input.district = {id:0,name:"请选择区/县"}; //省市区三级联动
		$scope.input.keywords = '';
		$scope.input.goodsChoice = 0;
		$scope.input.sellerChoice = 0;
		$scope.input.citysName = '定位中'; //宝山区
		$scope.supp_slider = new Array();
		$scope.brand_slider = new Array();
		$scope.news_slider = new Array();
		$scope.hots_slider = new Array();
		$scope.advs_slider_swiper = undefined;
		$scope.brand_slider_swiper = undefined;
		$scope.news_slider_swiper = undefined;
		$scope.hots_slider_swiper = undefined;
		$scope.search_open = false; //图片搜索开关 默认为关闭
		
		//关闭“打开app”
		$scope.doclose = function() {
			$scope.isNotApp = false;
		};
		/************模态窗口，选择搜索类型*************/
		$ionicPopover.fromTemplateUrl('templates/modal/keyindex.html', {
			scope: $scope
		}).then(function(popover) {
			$scope.popover = popover;
		});
		$scope.openSort = function($event) {
			$scope.popover.show($event);
		};
		$scope.closeSort = function() {
			$scope.popover.hide();
		};
		//销毁目标
		$scope.$on('$destroy', function() {
			$scope.popover.remove();
		});
		/************模态窗口*************/
		
		/************模态窗口*************/
		$ionicPopover.fromTemplateUrl('templates/modal/citys.html', {
			scope: $scope
		}).then(function(popover) {
			$scope.citypopover = popover;
			var items = new Array();
			var obj1 = { name: 'input.province' };
			var obj2 = { name: 'input.city' };
			var obj3 = { name: 'input.district' };
			items.push(obj1);
			items.push(obj2);
			items.push(obj3);
			GoAddress.init_load($scope, items);
		});
		$scope.openCity = function($event) {
			$scope.citypopover.show($event);
		};
		$scope.closeCity = function() {
			$scope.citypopover.hide();
		};
		//销毁目标
		$scope.$on('$destroy', function() {
			$scope.citypopover.remove();
		});
		$scope.doSelectProvince = function(){
			//id是值 name是显示
			GoDialog.showSelect("请选择省份",$scope.province_items,$scope.input.province,function(data){
				$scope.input.province = data;
			});
		}
		$scope.doSelectCity = function(){
			//id是值 name是显示
			GoDialog.showSelect("请选择城市",$scope.city_items,$scope.input.city,function(data){
				$scope.input.city = data;
			});
		}
		$scope.doSelectDistrict = function(){
			//id是值 name是显示
			GoDialog.showSelect("请选择区/县",$scope.district_items,$scope.input.district,function(data){
				$scope.input.district = data;
			});
		}
		//下拉侦听，目前只能省市区三级联动
		$scope.listen_province = function(data, obj) {
			if(!data){
				$scope.input.city = null;
				$scope.input.district = null;
				$scope.district_items = null;
			}else{
				$scope.input.city = data[0];
				$scope.input.citysName = data[0].name;
				$scope.input.district = null;
				$scope.district_items = null;
			}
		};
		$scope.listen_city = function(data, obj) {
			if(!data){
				$scope.input.district = null;
			}else{
				$scope.input.district = data[0];
				$scope.input.districtName = data[0].name;
			}
		};
		$scope.docitys = function() {
			if($scope.input.district == null) {
				GoDialog.toast('请选择区/县');
			} else {
				$scope.input.citysName = $scope.input.district.name;
				$scope.citypopover.hide();
				//请求转换
				var params = {
					province_name: $scope.input.province.name,
					city_name: $scope.input.city.name,
					district_name: $scope.input.district.name
				};
				//本地保存省市区
				Home.get_long_lat(params, function(data) {});
			}
		};
		/************模态窗口*************/
		//页面激活
		$scope.$on('$ionicView.afterEnter', function() {
			$scope.mail_timer = true;
			GoPage.init_top_home($scope);
			//用户类型 未登陆 or 制造商 or 终端用户都固定为“买家”
			$scope.user_type = Auth.check_user_type();
			
			if($scope.userIdForInit!=Auth.get_user_id()){//如果用户id不同，则重新初始化
				$scope.userIdForInit = Auth.get_user_id();
				$scope.init_data();
				$scope.init_data_nouser();
			}
//			$scope.init_data();
//			$scope.init_data_nouser();//不用每次进来都执行，接口过多

			//过度使用
			sessionStorage.removeItem("img-search-url");
			sessionStorage.removeItem("goods_id_search");
			//独自获取数据
			$scope.go_share_wx();
			//数据
			if(window.cordova && window.cordova.plugins) {
				$scope.is_app = true;
				$scope.isNotApp = false;
				if(ionic.Platform.isIOS()) {//判断是否ios
					$scope.isIOSApp = true;
				}else{
					$scope.isIOSApp = false;
				}
			} else {
				$scope.isIOSApp = false;
				if(GoWapAuth.isWeiXin()) {
					$scope.is_app = true;
					$scope.isNotApp = false;
				} else {
					$scope.is_app = false;
					$scope.isNotApp = true;
					getmailcount();//立即执行一次，避免30s后才去执行
					$scope.initMsgCount();//每隔30s执行一次
				}
			}
			//获取用户信息(人才市场)
			Home.getUserInfo(function(data) {
				$scope.userInfo_recruitment = data;
			});
		}, false);
		
		$scope.$on('$ionicView.afterLeave', function() {
			$scope.mail_timer = false;//不再请求站内信
			if($scope.mySupplierAnimateTimer){
				$interval.cancel($scope.mySupplierAnimateTimer);//必须取消动画定时器，否则动画不准
			}
		}, false);
		
		//定位获取
		$scope.init_area = function() {
			//设置保存
			var longitude = GoMap.get_homelocaltion("longitude");
			var latitude = GoMap.get_homelocaltion("latitude");
			var params = { longitude: longitude, latitude: latitude };
			//请求转换
			if(longitude != undefined) {
				$scope.get_location(params, function(data) {
					if($rootScope.init_localtion)
						$rootScope.init_localtion(data.district_id);
				});
			}
		};
		$scope.init_area();
		//定位获取
		$rootScope.init_localtion = function(district_id) {
			//地区初始化
			GoAddress.init_region($scope, district_id, function(val1, val2, val3) {
				//使用定时器来指引
				$scope.isUnwatch = true; //不进行侦听操作
				$scope.input.province = val1;
				$scope.input.city = val2;
				$scope.input.district = val3;
				$scope.input.citysName = val3.name;
				$timeout(function() {
					$scope.isUnwatch = false; //不进行侦听操作
				}, 1000);
			});
		};
		//图片搜索开关
		$rootScope.init_search_open = function(search_open) {
			$scope.search_open = search_open;
		};
		
		
		//获取站内信数量
		function getmailcount(){
			//用户当前使用身份 1买家 2卖家
			var isuser_type = Auth.check_issue_type();
			Home.getmailcount(isuser_type == 2 ? 1 : 0, function(data) {
				if(data.result != undefined) {
					$scope.mail_count = data.result.mail_count;
				} else {
					$scope.mail_count = 0;
				}
			});
		}
		
		//定时器获取站内信
		$scope.initMsgCount = function() {
			if($rootScope.hometimer == undefined) {
				//未读消息数量
				$rootScope.hometimer = $interval(function() {
					if($scope.mail_timer == true) {
						getmailcount();
					}
				}, 30000); //间隔30秒定时执行
			}
		};
		
		/********加载菜单数据************/
		$scope.init_data = function() {//固定菜单
			Home.getfixmenulist(function(data) {
				$scope.isLogin_menu = Auth.check_loginInfo();
				for(var i = 0; i < data.normal.length; i++) {
					//登录之后才能看
					if(data.normal[i].value == 'recruitment'||data.normal[i].value == 'searchorder'||data.normal[i].value == 'exchange_interaction') {
						if(!$scope.isLogin_menu) {
							data.normal[i].user_type = 0;
						}
					}
				}
				$scope.menus = data;
			});
		};
		//加载数据
		$scope.init_data_nouser = function() {
			//获取轮播区启用的内容
			Home.getbannerlist(function(data) {
				$scope.advs = data.associate;
				$timeout(function() {
					$scope.init_swiper_advs();
				}, 300);
			});
			//我的供应商列表
			Home.supplier_search(function(data) {
				if(data&&data.data) {
					var width = $window.innerWidth;
					$scope.supp_slider = data.data;
					$timeout(function(){//1s后滚动
						var mySupplier = document.getElementById("mySupplier");
						if(!mySupplier) return;
						var scrollWidth = mySupplier.scrollWidth - $window.innerWidth;//元素的宽度超出屏幕最大宽度多少
						if(scrollWidth<20) return;//必须大于10
						var duration = scrollWidth/30;
						handleMySupplierSpeed(mySupplier,duration,scrollWidth);
						$scope.mySupplierAnimateTimer = $interval(function(){
							handleMySupplierSpeed(mySupplier,duration,scrollWidth);		
						},duration*1000)
					},1000)
				}else{//没有数据时，必须new Array()，否则还是之前的数据
					$scope.supp_slider = new Array();
				}
			});
			//获取首页热门品牌列表
			Home.brand_getlist({
				nPage: 1
			}, function(data) {
				if(data != null) {
					//翻页处理
					for(var i = 0; i < data.page.tpage; i++) {
						$scope.brand_slider[i] = new Object();
						$scope.brand_slider[i].brands = new Array();
					}
					var temp = new Array();
					for(var i = 0; i < data.brand.length; i++) {
						if(temp.length == 3) {
							$scope.brand_slider[0].brands.push(temp);
							temp = new Array();
						}
						temp.push(data.brand[i]);
						if(i == data.brand.length - 1)
							$scope.brand_slider[0].brands.push(temp);
					}
				} else {
					$scope.brand_slider = new Array();
				}
				//因为使用到了swiper，必须要设置
				$timeout(function() {
					$scope.init_swiper_brand();
				}, 300);
			});
			//取得推荐的新品商品列表
			Home.news_getlist({
				nPage: 1
			}, function(data) {
				if(data != null) {
					//第一次初始化,按照总页数
					for(var i = 0; i < data.page.tpage; i++) {
						$scope.news_slider[i] = new Object();
						$scope.news_slider[i].goods = new Array();
					}
					if(data.page.tpage > 0)
						$scope.news_slider[0].goods = data.data;
				} else {
					$scope.news_slider = new Array();
				}
				//重新加载
				$timeout(function() {
					$scope.init_swiper_news();
				}, 300);
			});
			//热销产品
			Home.getHotList(1,function(data){
				$scope.hotList = data;
			})
			//9个活动
			Home.getActivities(function(data){
				$scope.activities = data;
				//直播图片16:9
				var allWidth = $window.innerWidth*0.5;
				$scope.zhiboHeight = allWidth*(9/16);
			})
		};
		
//		$scope.init_data();//菜单
//		$scope.init_data_nouser();//初始化主要数据
		/********加载菜单数据************/

		/********************************************************广告轮播图********************************************************/
		$scope.onshow_advs = function(item) {
			GoPage.go_advs(item.associate_type);
		};
		//初始化Swiper
		$scope.init_swiper_advs = function() {
			//现在这种情况下，图片可以自动轮播，但是当用手触碰之后，就会停止轮播，所以要再添加一个参数
			if($scope.advs_slider_swiper == undefined) {
				$scope.advs_slider_swiper = new Swiper('.swiper-container.advs', {
					loop: true,
					autoplay: 3000,
					pagination: '.swiper-pagination.advs',
					paginationClickable: true,
					spaceBetween: 30,
					autoplayDisableOnInteraction : false,  /* 注意此参数，默认为true */
					onSlideChangeEnd: function(swiper) {
						if(swiper.id == "advs") {

						}
					}
				});
				$scope.advs_slider_swiper.id = "advs";
			} else {
				if($scope.advs_slider_swiper.update)
					$scope.advs_slider_swiper.update(true);
				if($scope.advs_slider_swiper.slideTo)
					$scope.advs_slider_swiper.slideTo(0, 1000, false);
			}
		};
		
		/********************************************************品牌推荐********************************************************/
		//初始化Swiper
		$scope.init_swiper_brand = function() {
			if($scope.brand_slider_swiper == undefined) {
				$scope.brand_slider_swiper = new Swiper('.swiper-container.recommendBrand', {
					pagination: '.swiper-pagination.recommendBrand',
					paginationClickable: true,
					spaceBetween: 30,
					onSlideChangeEnd: function(swiper) {
						if(swiper.id == "brand") {
							$scope.initBrands(swiper.activeIndex);
						}
					}
				});
				$scope.brand_slider_swiper.id = "brand";
			} else {
				if($scope.brand_slider_swiper.update)
					$scope.brand_slider_swiper.update(true);
				if($scope.brand_slider_swiper.slideTo)
					$scope.brand_slider_swiper.slideTo(0, 1000, false);
			}
		};
		//列表
		$scope.initBrands = function(index) {
			var params = {
				nPage: index + 1
			};
			if($scope.brand_slider[index].brands.length == 0) {
				//取得热销的商品列表
				Home.brand_getlist(params, function(data) {
					if(data != undefined) {
						var temp = new Array();
						for(var i = 0; i < data.brand.length; i++) {
							if(temp.length == 3) {
								$scope.brand_slider[index].brands.push(temp);
								temp = new Array();
							}
							temp.push(data.brand[i]);
							if(i == data.brand.length - 1)
								$scope.brand_slider[index].brands.push(temp);
						}
						//因为使用到了swiper，必须要设置
						$timeout(function() {
							if($scope.brand_slider_swiper.update)
								$scope.brand_slider_swiper.update(true);
						}, 300);
					}
				});
			}
		};

		/********************************************************新品推荐********************************************************/
		//初始化Swiper
		$scope.init_swiper_news = function() {
			if($scope.news_slider_swiper == undefined) {
				$scope.news_slider_swiper = new Swiper('.swiper-container.news', {
					pagination: '.swiper-pagination.news',
					paginationClickable: true,
					spaceBetween: 30,
					onSlideChangeEnd: function(swiper) {
						if(swiper.id == "news") {
							$scope.initNews(swiper.activeIndex);
						}
					}
				});
				$scope.news_slider_swiper.id = "news";
			} else {
				if($scope.news_slider_swiper.update)
					$scope.news_slider_swiper.update(true);
				if($scope.news_slider_swiper.slideTo)
					$scope.news_slider_swiper.slideTo(0, 1000, false);
			}
		};
		//新品推荐翻页
		$scope.initNews = function(index) {
			var params = {
				nPage: index + 1
			};
			if($scope.news_slider[index].goods.length == 0) {
				//取得热销的商品列表
				Home.news_getlist(params, function(data) {
//					console.log(data)
					if(data != undefined) {
						$scope.news_slider[index].goods = data.data;
						//因为使用到了swiper，必须要设置
						$timeout(function() {
							if($scope.news_slider_swiper.update)
								$scope.news_slider_swiper.update(true);
						}, 300);
					}
				});
			}
		};

		//下拉刷新 判断哪个模块进行刷新
		$scope.doRefresh = function() {
			$scope.init_data();
			$scope.init_data_nouser();
			$timeout(function() {
				$scope.$broadcast('scroll.refreshComplete');
			}, 1000);
		};
		//菜单跳转--在相应的service.js里配置
		$scope.onshow_menu = function(value) {
			if(value != "recruitment" && value != "train") {
				GoPage.go_states(value);
			} else { 
				var info = Auth.get_loginInfo();
				if(!info) {
					GoDialog.confirm("请求失败", "请先登录", function() {
						GoPage.go_states("t-login");
					})
				} else if(info.verify_email != "Y") { //大写
					GoDialog.confirm("请求失败", "请先绑定邮箱", function() {
						GoPage.go_states("linkemail");
					})
				} else {
					GoPage.go_states(value);
					/*
					if(value == "recruitment"){
						//如果是人才市场，则跳转到第三方链接
						$scope.outUrl = HTTP_URL_RECRUITMENT + "?session=" + info.user_id;
						GoPage.go_link($scope.outUrl);
					}
					if(value == "train"){
						GoPage.go_states(value);
						//如果是培训，则跳转到第三方链接
						$scope.outUrl = HTTP_URL_TRAIN + "?session=" + info.user_id;
					}
					*/
				}
			}
		};
		
		//商品详情--新品、热销
		$scope.onshow_productdetail = function(goods_id, store_id, type) {
			GoPage.go_states("productdetail", {
				"goods_id": goods_id,
				"type": type
			});
		};
		//"立即购买"，跳转到商品检索页面
		$scope.onshow_afsrue = function(obj) {
			sessionStorage.setItem("goods_id_search", obj.goods_id);
			GoPage.go_states("productsearch", {
				"top_search_flag": $scope.input.sellerChoice,
				"st": $scope.input.goodsChoice == 0 ? 'g' : 'b',
				"keywords": "",
				"brand_id": 0,
				"cat_id": 0,
				"goods_name": obj.name
			});
		};
		
		//收藏
		$scope.onfavority = function(obj) {
			var params = {
				goods_id: obj.goods_id
			};
			//有人写错字段
			if(obj.favotire == undefined) {
				if(obj.favorite == 1) {
					Home.favoritedel_getlist(params, function(data) {
						obj.favorite = 0;
					}, function() {
						//登录跳转
						if(!Auth.check_loginInfo()) {
							GoPage.go_states("t-login");
						} else {
							GoDialog.toast('收藏失败');
						}
					});
				} else {
					Home.favoriteadd_getlist(params, function(data) {
						obj.favorite = 1;
					}, function() {
						//登录跳转
						if(!Auth.check_loginInfo()) {
							GoPage.go_states("t-login");
						} else {
							GoDialog.toast('收藏失败');
						}
					});
				}
			} else {
				if(obj.favotire == 1) {
					Home.favoritedel_getlist(params, function(data) {
						obj.favotire = 0;
					}, function() {
						//登录跳转
						if(!Auth.check_loginInfo()) {
							GoPage.go_states("t-login");
						} else {
							GoDialog.toast('收藏失败');
						}
					});
				} else {
					Home.favoriteadd_getlist(params, function(data) {
						obj.favotire = 1;
					}, function() {
						//登录跳转
						if(!Auth.check_loginInfo()) {
							GoPage.go_states("t-login");
						} else {
							GoDialog.toast('收藏失败');
						}
					});
				}
			}
		};
		
		//搜索
		$scope.onshow_productsearch = function() {
			GoPage.go_states("productsearch", {
				"top_search_flag": $scope.input.sellerChoice,
				"st": $scope.input.goodsChoice == 0 ? 'g' : 'b',
				"keywords": $scope.input.keywords,
				"brand_id": 0,
				"cat_id": 0
			});
		};
		//我的品牌（跳转商品检索）
		$scope.onshow_brand = function(obj) {
			GoPage.go_states("productsearch", {
				"top_search_flag": $scope.input.sellerChoice,
				"st": $scope.input.goodsChoice == 0 ? 'g' : 'b',
				"keywords": "",
				"brand_id": obj.brand_id,
				"brand_name": obj.brand_name,
				"cat_id": 0
			});
		};
		//我的供应商（不应跳转到商品检索页面）
		$scope.onshow_distributor_sxqd = function() {
			GoPage.go_states("distributor_sxqd");
		}

		//更多分类
		$scope.do_more_calss = function(obj) {
			GoPage.go_states("productsearch", {
				"top_search_flag": $scope.input.sellerChoice,
				"st": $scope.input.goodsChoice == 0 ? 'g' : 'b',
				"keywords": "",
				"brand_id": 0,
				"cat_id": obj.cat_id,
				"cat_name": obj.cat_name
			});
		};
		
		/*
		 * 9个活动
		 * 活动类型
			1=>团购活动
			2=>秒杀活动
			3=>限时抢购活动
			4=>拍卖活动
			5=>新品测试活动
			6=>新品赠送活动
			7=>新品公告活动
			8=>产品推广活动
			9=>产品促销活动
		 */
		$scope.onshow_activity = function(type){
			if(type==1 || type==2 || type==4 || type==8 || type==9 ){
				if($scope.user_type==5){
					GoDialog.alert("提示","店铺身份才能参加此活动！");
					return;
				}
			}
			GoPage.go_states("activity",{"type":type});
		}
		
		$scope.onshow_paimami = function(){
			GoPage.go_states("panicauction");//限时拍卖
		}
		
		//我的供应商
		$scope.onshow_shop = function(obj) {
			GoPage.go_states("first", {
				"store_id": obj.store_id
			});
		};
		//我的消息
		$scope.onshow_message = function(store_id) {
			if(Auth.check_loginInfo()) {
				GoPage.go_states("t-message");
			}else{
				GoDialog.alert("提示","请先登录！");
			}
		};
		//滚动侦听
		$scope.doShowTop = function(name, index) {
			var delegate = $ionicScrollDelegate.$getByHandle(name);
			if(delegate.getScrollPosition() == undefined) return;
			var scrollTop = delegate.getScrollPosition().top;
			//分类
			$scope.$apply(function() {
				if($window.innerHeight <= delegate.getScrollPosition().top) {
					$scope.showtop999 = "show";
				} else {
					$scope.showtop999 = "hide";
				}
			});
		};
		//回到顶部
		$scope.doScrollToTop = function(name, index) {
			$ionicScrollDelegate.$getByHandle(name).scrollTop(true);
		};
		//图片检索
		$scope.onshow_imgsearch = function() {
			//图片上传
			GoPicture.upload(function(res) {
				if(!res.success) {
					GoDialog.toast(res.msg);
					return;
				}
				//图片检索//过度使用
				sessionStorage.setItem("img-search-url", res.result.image_src);
				GoPage.go_states("productsearch", {
					"top_search_flag": $scope.input.sellerChoice,
					"st": $scope.input.goodsChoice == 0 ? 'g' : 'b',
					"keywords": "",
					"brand_id": 0,
					"cat_id": 0
				});
			});
		};

		//分享（自定义每个页面的参数）
		$scope.go_share_wx = function() {
			//分享打开
			GoWapAuth.execisoff(false);
			//设置分享
			var param = new Object();
			if($scope.detail) {
				param.title = undefined;
				param.desc = undefined;
				param.thumb = undefined;
				param.link = undefined;
			}
			GoWapAuth.execshare(param);
		}
		//打开二维码扫码
		$scope.onshow_scan = function() {
			if(GoWapAuth.isWeiXin()) {
				//微信扫码结果
				GoWapAuth.scanWX(function(result) {
					var url = result.resultStr;
					url = url.replace("http://www.wlwj.com/index.php/shop-view-", "");
					url = url.replace(".html", "");
					if(!isNaN(url)) {
						GoPage.go_states("first", {
							"store_id": url
						});
					} else {
						GoPage.go_link(result.resultStr);
					}
				});
			} else {
				//扫码
				GoScan.barcodeScanner(function(result) {
					//取消不做处理
					if(!result.cancelled) {
						//http://www.wlwj.com/index.php/shop-view-29.html
						//字符替换操作
						var url = result.text;
						url = url.replace("http://www.wlwj.com/index.php/shop-view-", "");
						url = url.replace(".html", "");
						if(!isNaN(url)) {
							GoPage.go_states("first", {
								"store_id": url
							});
						} else {
							GoPage.go_link(result.text);
						}
					}
				});
			}
		}
		
		/******************优化新增**************/
		//动画。mySupplier为dom对象，duration滚动一次需要的时间，scrollWidth滚动的距离
		function handleMySupplierSpeed(mySupplier,duration,scrollWidth){
			var node = angular.element(mySupplier);
			$scope.mySupplierAnimate = null;
			var leftWidth = mySupplier.style.left;//如-171px，根据此判断是向左还是向右
			if(leftWidth==-scrollWidth+"px"){
				$scope.mySupplierAnimate = $animateCss(node, {
					from: { 'left': -scrollWidth+"px"},//right没效果
					to: { 'left': "0px"},
					duration: duration//s数字越大，速度越慢
				});
			}else{
				$scope.mySupplierAnimate = $animateCss(node, {
					from: { 'left': "0px"},
					to: { 'left': -scrollWidth+"px"},
					duration: duration//s数字越大，速度越慢
				});
			}
			$scope.mySupplierAnimate.start();
		}
		
		/******************加载更多热销产品**************/
		$scope.isLoad = false;
		$scope.nPage = 1;
		$scope.doRefreshMore = function() {
			//防止重复加载
			$scope.isLoad = true;
			Home.getHotList($scope.nPage + 1, function(data) {
				if(data&&data.cat) {
					if($scope.hotList !=undefined&&$scope.hotList.cat != undefined) {
						$scope.hotList.cat = $scope.hotList.cat.concat(data.cat);
						$scope.nPage += 1;
					} else {
						$scope.hotList = data;
					}
				}
			},function() {
				$scope.$broadcast('scroll.infiniteScrollComplete');
				$timeout(function() {
					$scope.isLoad = false;
				}, 1500);
			});
		};
		
		//选择商品/品牌
		$scope.goodsChoice = function(val){
			$scope.input.goodsChoice = val;
			$scope.popover.hide();
		}
		
		
	}

	controller.$inject = ['$scope', '$rootScope', 'GoWapAuth', 'Home', 'Auth', 'GoPage', 'GoDialog', 'GoAddress', 'GoMap', 'GoPicture', '$window', '$timeout', '$interval', '$ionicSlideBoxDelegate', '$ionicScrollDelegate', '$ionicModal', '$ionicPopover', '$sce', 'GoScan','$animateCss'];

	return app.registerController("homectrl", controller);
});